package com.cloudfactory.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.cloudfactory.po.Activity;
import com.cloudfactory.po.City;
import com.cloudfactory.service.ActivityService;
import com.cloudfactory.service.CityService;

@Controller
@RequestMapping(value = "/")
public class ActivityController {

	@Autowired
	private CityService cityService;

	@Autowired
	private ActivityService activityService;

	@RequestMapping(value = "/activity")
	public String activity(Model model) {
		List<City> cityList = cityService.selectAll();
		List<Activity> activityList = activityService.selectAll();
		model.addAttribute("cityList", cityList);
		model.addAttribute("activityList", activityList);
		return "/activity.jsp";
	}

	@RequestMapping(value = "/activity-content")
	public String activityContent(Model model, @RequestParam("id") Long id) {
		Activity activity = activityService.selectById(id);
		model.addAttribute("activity", activity);
		return "/activity-content.jsp";
	}
}
